<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      /* 外边距bug1：兄弟组件都设置外边距会导致合并
      box1设置下边距，box2设置上边距，导致外边距合并*/
      div {
        width: 100px;
        height: 100px;
        background-color: aqua;
      }
      .box1 {
        margin-bottom: 50px;
      }
      .box2 {
        background-color: pink;
        margin-top: 20px;
      }
      /* 解决办法，加个父组件设置为flex布局 */
      .father {
        display: flex;
        flex-direction: column;
      }
    </style>
  </head>
  <body>
    <aside class="father">
      <div class="box1"></div>
      <div class="box2"></div>
    </aside>
  </body>
</html>
